package com.example.datapedestal.utils;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Map;

/**
 * @author: ThinkPad
 * @since: 2023/10/27 10:55
 * @description:
 */
public class JsonToMapExample {
    private static final ObjectMapper objectMapper = new ObjectMapper();
//    把json字符串转为map。
    public static Map convert(String json){
        try {
             return objectMapper.readValue(json, new TypeReference<Map<String, Object>>() {});
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
